package com.caine.androidtask.ls04;

import android.app.Activity;
import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.PopupWindow;

public class Ls04 extends Activity {
	@SuppressWarnings("unused")
	private Button btn_cancel;
	private Button btn_popup;
	PopupWindow popup;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);

		final LinearLayout layout = new LinearLayout(this);
		layout.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
		layout.setOrientation(LinearLayout.VERTICAL);
		btn_popup = new Button(this);
		btn_popup.setGravity(Gravity.CENTER_VERTICAL);
		btn_cancel = new Button(this);		
		layout.addView(btn_popup);
		setContentView(layout);
		btn_popup.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
//				LinearLayout ly = new LinearLayout(getApplicationContext());
//				ly.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));
//				ly.setOrientation(LinearLayout.HORIZONTAL);
//				ly.addView(btn_cancel,Gravity.BOTTOM);
				popup = new PopupWindow();		
				popup.showAsDropDown(v);
			}
		});
	}
}
